﻿using NxChatQQ.Models;
using NxChatQQ.Models.Enums;
using System.Windows;
using System.Windows.Controls;

namespace NxChatQQ.Selectors
{
    /// <summary>
    /// 消息气泡样式
    /// </summary>
    public class ChatMessageSelector : DataTemplateSelector
    {
        public DataTemplate TextMsgTemplate { get; set; }

        public DataTemplate ImageMsgTemplate { get; set; }

        public DataTemplate GiftMsgTemplate { get; set; }

        public DataTemplate EmojiMsgTemplate { get; set; }

        public DataTemplate RemindMsgTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            DataTemplate result = new DataTemplate();
            MessageObject messageObject = item as MessageObject;

            switch (messageObject.Type)
            {
                case kWCMessageType.Text:
                    result = TextMsgTemplate;
                    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_CUSTOM_EMOJI:
                    //    result = ResourceHelper.GetResource<DataTemplate>("FriendCustomEmojiMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_EMOJI:
                    //    result = EmojiMsgTemplate;
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_IMAGE:
                    //    result = ImageMsgTemplate;
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_VIDEO:
                    //    result = ResourceHelper.GetResource<DataTemplate>("FriendVideoMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_GIFT2:
                    //    result = GiftMsgTemplate;
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_RANDOM_GIFT:
                    //    result = ResourceHelper.GetResource<DataTemplate>("FriendGiftMessageTemplate2");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_ROOM_TIP_CONTENT:
                    //    result = RemindMsgTemplate;
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_NOTICE:
                    //case AiyiMessageType.ONLY_TYPE_RECHARGE:
                    //    result = ((!(messageObject.objectId == "开播提醒")) ? ResourceHelper.GetResource<DataTemplate>("FriendNoticeMessageTemplate") : ResourceHelper.GetResource<DataTemplate>("FriendLiveOpenMessageTemplate"));
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_IMAGE_TEXT:
                    //    result = ResourceHelper.GetResource<DataTemplate>("FriendImageTextMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_SPARK_MESSAGE:
                    //    messageObject.OtherObj = JSONParse.Deserialize<SparkObject>(messageObject.content);
                    //    result = ResourceHelper.GetResource<DataTemplate>("FriendSparkMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_SHARE_ROOM:
                    //    {
                    //        ShareUser shareUser2 = (ShareUser)(messageObject.OtherObj = JSONParse.Deserialize<ShareUser>(messageObject.content));
                    //        result = ((shareUser2.spouseRoomId <= 0) ? ((!messageObject.IsMysend) ? ResourceHelper.GetResource<DataTemplate>("FriendShareLiveMessageTemplate") : ResourceHelper.GetResource<DataTemplate>("MyShareLiveMessageTemplate")) : ResourceHelper.GetResource<DataTemplate>("WeddingInviteMessageTemplate"));
                    //        break;
                    //    }
                    //case AiyiMessageType.ONLY_TYPE_CHAT_RELIEVE_RELATION:
                    //    result = ResourceHelper.GetResource<DataTemplate>("RelationMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_MARRY_NOTICE:
                    //    if (messageObject.OtherObj is MarrySystemNoticeAttach marrySystemNoticeAttach)
                    //    {
                    //        messageObject.content = (messageObject.IsMysend ? marrySystemNoticeAttach.from_content : marrySystemNoticeAttach.to_content);
                    //        result = RemindMsgTemplate;
                    //    }
                    //    else
                    //    {
                    //        result = RemindMsgTemplate;
                    //    }
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_DIVORCE_APPLY:
                    //    result = ResourceHelper.GetResource<DataTemplate>("DivorceApplyMessageTemplate");
                    //    break;
                    //case AiyiMessageType.ONLY_TYPE_CHAT_PROPOSE:
                    //    result = ResourceHelper.GetResource<DataTemplate>("ProposeApplyMessageTemplate");
                    //    break;
                    //default:
                    //    messageObject.content = "未能识别的消息类型:" + (int)messageObject.type;
                    //    messageObject.type = AiyiMessageType.ONLY_TYPE_CHAT_IMAGE_TEXT;
                    //    result = TextMsgTemplate;
                    //    break;

            }
            return result;
        }
    }

}